function debounce(fn, time = 300) {
  let timeout = null
  return function(...args) {
    if (timeout) {
      clearTimeout(timeout)
    }
    timeout = setTimeout(() => {
      fn.apply(this, args)
    }, time)
  }
}

export default debounce
